package org.smile.jstl.tags.pager;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.jsp.JspException;

import org.smile.jstl.tags.pager.PagerTagSupport;


/**
 * @author 胡真山
 */
public class ParamsTag extends PagerTagSupport {
	
	/**
	 * 一个封闭了要传的参数的map
	 */
	private Object paramMap;
	
	public ParamsTag(){
		paramMap=null;
	}
	public Object getParamMap() {
		return paramMap;
	}

	public void setParamMap(Object paramMap) {
		this.paramMap = paramMap;
	}

	public final int doStartTag()
    throws JspException
	{
	    super.doStartTag();
	    Map params=(Map)paramMap;
	    Set keySet=params.keySet();
	    for(Iterator itor=keySet.iterator();itor.hasNext();){
	    	String key=itor.next().toString();
	    	 pagerTag.addParam(key, params.get(key)==null?"":params.get(key).toString());
	    }
	    return EVAL_BODY_INCLUDE;
	}
	
	public final void release()
	{
	   paramMap=null;
	    super.release();
	}
}
